#include "led.h"

void led_func(uint8_t *led)
{
	uint8_t temp = 0x00;
	static uint8_t old_temp = 0xff;
	
	for(int i=0;i<8;i++)
	{
		temp |= (led[i]<<i);
	}
	
	if(temp != old_temp)
	{
		GPIOC->ODR &= 0x00ff;
		GPIOC->ODR |= ~(temp<<8);
		
		GPIOD->BSRR |= 0x01<<2;
		GPIOD->BRR |= 0x01<<2;
		
		old_temp = temp;
	}
}
	
uint8_t uled[8] = {0,0,0,0,0,0,0,0};
void led_proc(void)
{
	uled[0] = (show_mode == 0);
	uled[1] =( Freq[0] > PH);
	uled[2] = (Freq[1] > PH);
	uled[7] = (NB[0] >= 3 || NA[0]>=3);
	led_func(uled);
}